package com.ctrip.demo.java8;

import com.ctrip.demo.proxy.User;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

public class ListTest {

    public static void main(String[] args) {
        List<User> list = new ArrayList<>();

        list.add(null);
        list.add(new User("zhangsan"));

        List<String> collect = list.stream().filter(Objects::nonNull).map(a -> a.getName()).collect(Collectors.toList());
        System.out.println(collect);
    }
}
